<?php 
include('header.php'); 

if( isset( $_POST['name'] ) ) {
	require('inc/db.php');
	$name = $_POST['name'];
	$phone = $_POST['phone'];
	$subject = $_POST['subject'];
	$content = $_POST['content'];

	$sql = "insert into message(name, phone, subject,content) values ('$name', '$phone', '$subject','$content')";

	$result = mysql_query($sql, $conn);

	if( $result ) {
		$message = "感谢您提交信息，我们会尽快与您取得联系";
	}
	else {
		$message = "提交信息失败，请稍后重试";
	}
}

?>	

<div class="wrapper">
	<div class="main">
		<div class="bcl">
    		<div class="title">新闻中心</div>
            <div class="kuang">
            	<ul>
                	<li><a href="news_list.php?sort=kaiye">凯业新闻</a></li>  
      			  	<li><a href="news_list.php?sort=fagui">政策法规</a></li>
              	  	<li><a href="news_list.php?sort=hangye">行业新闻</a></li>
      			</ul>
            </div>
        </div>
        
        
        <div class="main_right">
    		<div class="title">在线交流</div>
        	<div class="message">
        		<p>
        			请尽量详细的告知您的信息，我们将严格为您保密。  			
        		</p>
        		
        		<?php 
        			if( isset($message) ) {
        				echo "<p class=\"note\">$message</p>";
        		?>
        				<div class="blank2"></div>
        		<?php 
        			}
        		?>
        		
				<form action="message.php" method="post">
					<table>
						<tr>
							<th>主题：</th>
							<td>
								<select name="subject">
									<option value="1">我要买房</option>
									<option value="2">我要卖房</option>
									<option value="3">我要租房</option>
									<option value="4">我要出租</option>
									<option value="4">在线留言</option>
									<option value="4">投诉建议</option>
								</select>
							</td>
						</tr>
						<tr>
							<th>您的姓名：</th>
							<td><input type="text" name="name" size="20" /></td>
						</tr>
						<tr>
							<th>联系电话：</th>
							<td><input type="text" name="phone" size="30" /></td>
						</tr>
						<tr>
							<th>内容：</th>
							<td><textarea rows="8" cols="50" name="content"></textarea></td>
						</tr>
						<tr>
							<th>&nbsp;</th>
							<td><input type="submit" value="提交" /></td>
						</tr>
					</table>
				</form>
				
				<div class="blank3"></div>
				
        	</div>
        </div>
	</div>
</div>
<?php include('footer.php') ?>



